import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * Created by IntelliJ IDEA.
 * User: seth.yang
 * Date: 12-5-14
 * Time: 下午6:11
 */
public class HttpTest {
    public static void main (String[] args) throws Exception {
        URL url = new URL ("http://www.raychn.com/passport/sso-channel");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection ();
        conn.setRequestMethod ("POST");
        conn.setDoInput (true);
        conn.setDoOutput (true);

        OutputStream out = conn.getOutputStream ();
        PrintWriter pw = new PrintWriter (out, true);
        pw.println ("key=25f303c3");
//        pw.println ();
        pw.flush ();
        out.flush ();

        int response_code = conn.getResponseCode ();
        System.out.println ("conn.getResponseMessage () = " + conn.getResponseMessage ());

        System.out.println ("response_code = " + response_code);
/*
        if (response_code != 200) {
            System.out.println ("response_code = " + response_code);
        } else {
*/
            InputStream in = conn.getInputStream ();
            byte[] buff = new byte[1024];
            int length;
            while ((length = in.read (buff)) != -1)
                System.out.write (buff, 0, length);
//        }
    }
}
